//
//  GiftItemView.m
//  tcpoctest
//
//  Created by gump on 5/29/13.
//  Copyright (c) 2013 gump. All rights reserved.
//

#import "GiftItemView.h"
#import "GiftInfoDataSource.h"
#import "giftSendView.h"
#import "ListInfoGiftView.h"

@implementation GiftItemView

-(void)ReSetImageByID:(NSString *)strid
{
    NSString *imagepath = [[DataControl shareControl].giftInfoDS searchGiftImagePath:strid];
    if (![imagepath isEqualToString:@""]) {
        self.giftImageView.image = [UIImage imageWithContentsOfFile:imagepath];
    }
    else
    {
        self.giftImageView.image = [UIImage imageNamed:@"gift_default.png"];
    }
}

-(void)initUI
{
    self.giftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 60, 60)];
    self.giftImageView.userInteractionEnabled = YES;
    
    UITapGestureRecognizer *singleTouch = [[UITapGestureRecognizer alloc] initWithTarget:self
                                                                                  action:@selector(imageTap:)];
    [self.giftImageView addGestureRecognizer:singleTouch];
    
    self.giftLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 88, 80, 20)];
    self.giftLabel.textAlignment = UITextAlignmentCenter;
    self.giftLabel.backgroundColor = [UIColor clearColor];
    self.giftLabel.font = [UIFont boldSystemFontOfSize:14.0f];
    self.giftLabel.textColor = [UIColor darkGrayColor];
    
    self.giftNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 70, 80, 20)];
    self.giftNameLabel.textAlignment = UITextAlignmentCenter;
    self.giftNameLabel.backgroundColor = [UIColor clearColor];
    self.giftNameLabel.font = [UIFont boldSystemFontOfSize:14.0f];
    self.giftNameLabel.textColor = [UIColor darkGrayColor];
    
    [self addSubview:self.giftImageView];
    [self addSubview:self.giftLabel];
    [self addSubview:self.giftNameLabel];
}

-(void)imageTap:(id)sender
{
    [[ViewManager sharedViewManager].giftListInfoVC HideTypeList];
    
    [ViewManager sharedViewManager].giftsendvc.ginfo = self.ginfo;
    
    [[ViewManager sharedViewManager] showView:VI_GIFT_SEND
                             withIsRemoveCurV:false
                                withDirection:VD_NULL];
}

@end
